package ro;

import java.util.ArrayList;

public class Partition {
	ArrayList<Edge> partitions;
	ArrayList<Boolean> inclues;
	

        /**
         *
         * @param aretes The list of Edge of the partition
         * @param inclusion The list which indicates if an Edge is included or not
         */
	public Partition(ArrayList<Edge> aretes, ArrayList<Boolean> inclusion){
		partitions = (ArrayList<Edge>)aretes.clone();
		inclues = (ArrayList<Boolean>)inclusion.clone();
		
	}
	

        /**
         *
         * @return The list of Edge of the partition
         */
	public ArrayList<Edge> getAretes(){
		return partitions;
	}

        /**
         *
         * @param i the index of the list
         * @return the Edge at index i
         */
	public Edge get(int i){
            if(i>=partitions.size())
                return null;
            return partitions.get(i);
	}

        /**
         *
         * @return The inclusion list
         */
	public ArrayList<Boolean> getBool(){
		return inclues;
	}


        /**
         *
         * @return The weight of the partition
         */
	public int getPoids(){
		int res = 0;
		for(int i=0; i< partitions.size(); i++){
			if(getIncl(i))
                            res+= partitions.get(i).weight;
                        
		}
		return res;
	}

        /**
         *
         * @param index the index of the list
         * @return True or false if the Edge is included or not
         */
        public Boolean getIncl(int index){
            return inclues.get(index);
        }

	
	public String toString(){
		String res = "";
		
		for(int i=0; i<partitions.size(); i++){
			if(inclues.get(i)) 
                            res = res + partitions.get(i);
		}
		return res+"\n";
	}

}
